package net.onceface.application.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.onceface.application.dto.SpecDTO;
import net.onceface.core.domain.Spec;

public class SpecAssembler {

	public static SpecDTO toDTO(Spec spec){
		if(spec == null){
			return null;
		}
		SpecDTO result = new SpecDTO();
		result.setId(spec.getId());
		result.setVersion(spec.getVersion());
		result.setName(spec.getName());
		result.setStock(spec.getStock());
		result.setPrice(spec.getPrice());
		result.setOriginalPrice(spec.getOriginalPrice());
		return result;
	}
	
	public static Spec toEntity(SpecDTO spec){
		if(spec == null){
			return null;
		}
		Spec result = new Spec();
		result.setId(spec.getId());
		result.setVersion(spec.getVersion());
		result.setName(spec.getName());
		result.setStock(spec.getStock());
		result.setPrice(spec.getPrice());
		result.setOriginalPrice(spec.getOriginalPrice());
		return result;
	}
	
	public static List<Spec>  toEntities(Collection<SpecDTO>  specs){
		if (specs == null) {
			return null;
		}
		List<Spec> results = new ArrayList<Spec>();
		for (SpecDTO each : specs) {
			results.add(toEntity(each));
		}
		return results;
	}
	
	public static List<SpecDTO>  toDTOs(Collection<Spec>  specs){
		if (specs == null) {
			return null;
		}
		List<SpecDTO> results = new ArrayList<SpecDTO>();
		for (Spec each : specs) {
			results.add(toDTO(each));
		}
		return results;
	}
}
